<?php
/**
 * XuYuan Project
 *
 * @package	XueYuan 
 * @author	Jiuchi Team
 * @since	Version 1.0.0
 * @filesource
 */
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * User model class
 * @author Wayne Yu
 */
class Circle_model extends Jiuchi_Model{
	/**
	 * Construct function
	 */
	public function __construct() {
		parent::__construct();
		$this->table = 'circle';
	}
	
	/**
	 * Check circle name
	 */
	public function checkCircleName($name){
		$count = 1;
		$res = $this->retrieve($count, NULL, NULL, NULL, array('name' => $name));
		if($res > 0){
			return FALSE;
		} else{
			return TRUE;
		}
	}
	
	public function getAllCircles($pageSize = 0, $lastItem = 0, $where=NULL, $like = NULL, $orderBy = 'updated_at', $direction = 'DESC'){
		$count = -1;
		if(!isset($where['deleted'])) $where['deleted'] = 0;
		return $this->retrieve($count, $pageSize, $lastItem, NULL, $where, $orderBy, $direction, NULL, $like);
	}
	
	/*----------------------------------------------------*/
	/**
	 * Admin
	 */
	public function getAllCircle(){
		$count = -1;
		return $this->retrieve($count, NULL, NULL, NULL, array('deleted'=>0), NULL, NULL, NULL, array());
	}

	public function delTopic($topicId){
		$this->markDeleted($topicId);
	}
}